package cn.smbms.pojo;

public class Page {
	public static final int DEFAULT_PAGE_SIZE = 10;

	private int pageNo = 1; // 当前页, 默认为第1页
	private int pageSize = DEFAULT_PAGE_SIZE; // 每页记录数
	private long totalRecord = -1; // 总记录数, 默认为-1, 表示需要查询
	private int totalPage = -1; // 总页数, 默认为-1, 表示需要计算
	private int start = 0;
	
	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
		if (getPageSize() > 0 && getTotalRecord() > -1) {  
            this.totalPage = (int) (getTotalRecord() % getPageSize() == 0 ? getTotalRecord() / getPageSize() : getTotalRecord() / getPageSize() + 1);  
        }  
	}

	public long getTotalRecord() {
		return totalRecord;
	}

	public void setTotalRecord(long totalRecord) {
		this.totalRecord = totalRecord;
		if (getPageSize() > 0 && getTotalRecord() > -1) {
			this.totalPage = (int) (getTotalRecord() % getPageSize() == 0 ? getTotalRecord() / getPageSize()
					: getTotalRecord() / getPageSize() + 1);
		}
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
}
